<template>
  <div class="player">
    <!-- 视频播放器 -->
    <video :src="videoUrl" controls class="video-player">
      您的浏览器不支持视频播放。
    </video>

    <!-- 相关推荐图片 -->
    <div class="related-images">
      <h3>相关推荐</h3>
      <div class="image-grid">
        <img
          v-for="(image, index) in relatedImages"
          :key="index"
          :src="image"
          alt="推荐图片"
          class="related-image"
          @click="playVideo(image)"
        />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

// 视频地址
const videoUrl = ref('http://codelover.club/coursefiles/lnnpREORzoIdSs-hRgPHOKXVIzwM.mp4');

// 推荐图片资源
const relatedImages = ref([
  'https://codelover.club/coursefiles/images/film/创意.jpeg',
  'https://codelover.club/coursefiles/images/film/剧情.jpeg',
  'https://codelover.club/coursefiles/images/film/动画.jpeg',
  'https://codelover.club/coursefiles/images/film/励志.jpeg',
  'https://codelover.club/coursefiles/images/film/实验.jpeg',
  'https://codelover.club/coursefiles/images/film/广告.jpeg',
  'https://codelover.club/coursefiles/images/film/搞笑.jpeg'
]);

// 点击推荐图片时更新视频
const playVideo = (imageSrc: string) => {
  // 这里可以添加逻辑，根据点击的图片加载对应的视频
  console.log('点击了推荐图片:', imageSrc);
};
</script>

<style scoped>
.player {
  padding: 20px;
  text-align: center;
}

.video-player {
  width: 80%;
  max-width: 800px;
  height: auto;
  margin-bottom: 20px;
}

.related-images {
  margin-top: 20px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  margin-top: 10px;
}

.related-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  cursor: pointer;
  border-radius: 8px;
  transition: transform 0.3s ease;
}

.related-image:hover {
  transform: scale(1.05);
}
</style>